cc.Class({
    extends: cc.Component,

    properties: {

    },
    onLoad () {
        let basePath = 'Canvas/gameBox/commTop/';
        //时间： 00：00
        this.timeStrLabel = cc.find(basePath+'timebg/timeStr').getComponent(cc.Label);
        //得分
        this.scoreLabel = cc.find(basePath+'score/label').getComponent(cc.Label);   

        this.keyMap = {
            'time': this.timeStrLabel,
            'score': this.scoreLabel,
        }
        this.node.on('updateNum', (map)=>{
            for(let name in map){
                let val = map[name];
                if(name == 'time'){
                    val = this.getTime(val)
                }
                this.keyMap[name].string = val;
            }
        })
    },
    //补零
    add0(num){
        if(num<0){
            num = 0;
        }
        return num<=9?'0'+num:''+num
    },
    getTime(num){
        let minutes = this.add0(Math.floor(num/60));
        let seconds = this.add0(num%60);
        return minutes+':'+seconds
    },
    start () {

    },

    // update (dt) {},
});
